function $(id){
  return document.getElementById(id);
}
//导入JS函数
function insertJS(src){
 var script = document.createElement("SCRIPT"), done = false;
 script.type = "text/javascript";
 script.src = src;
 script.charset = "GB2312";
 script.onload = script.onreadystatechange = function(){
  if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) {
   done = true;
  }
 };
 document.getElementsByTagName("HEAD")[0].appendChild(script);
}
//导入需要用到的JS
insertJS("./dwr/interface/WeatherBean.js")
insertJS("./dwr/interface/ConsumerBean.js")
insertJS("./dwr/engine.js")
insertJS("./dwr/util.js")
insertJS("./dwr/interface/CommodityhouseBean.js")

window.onload=function(){
	$("getweather").innerHTML="正在获取天气数据...";
	CommodityhouseInfo();
	setTimeout("ajaxWeather()",100);
	
}
function CommodityhouseInfo(){
 				CommodityhouseBean.FindAllLimit(CommodityhouseData);
			}
			function CommodityhouseData(data){
			
			var str='';
			 for(var i=0;i<data.length;i++){
			 str+="<dd><div><a href='commodityHouse!FindById.action?id="+data[i].id+"' target='_blank'><img src='/housNet/images/HousePic/"+data[i].chPic+"' alt='' width='136' height='86' /> </a></div><a href='commodityHouse!FindById.action?id="+data[i].id+"' target='_blank' class='a1 fontbd'>"+data[i].chName+"</a><a class='a1' style='color: red;'>"+data[i].chPhone+"</a><a href='commodityHouse!FindById.action?id="+data[i].id+"' target='_blank'>详情</a> |<span style='color: #999;'>视频</span></dd>"
			
			 }
			 alert(str);
			  $("indexCommodityhouse").innerHTML=str;

			}

//获取天气
function ajaxWeather(){
	//远程调用服务端的异步获取天气方法，并指定回调函数
	WeatherBean.returnWeater(getAjaxWeather);
}
//AjaxBean.ajaxWeather的回调函数
function getAjaxWeather(date){
	if(date.length>0){
		$("getweather").innerHTML = "<img src='images/weather/"+date[2]+"' align='bottom'/> "+date[1]+" "+date[0];
	}else{
		$("getweather").innerHTML = "fddhdfh";
	}
}
//用户登录
function ajaxLogin(){
	var ln = DWRUtil.getValue("loginName");
      	var lp = DWRUtil.getValue("loginPwd");
	//远程调用服务端的异步登录方法，并指定回调函数
	ConsumerBean.Login(ln,lp,getAjaxLogin);
}
//AjaxBean.ajaxWeather的回调函数
function getAjaxLogin(date){

	if(date.length>0){
		document.getElementById("loginuser").innerHTML = '<SPAN style="COLOR: red">登录状态：已登录</SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp;用户名：'+date[0].CLoginName+'&nbsp;&nbsp;&nbsp;<A style="COLOR: #006600" href="#" target=_blank>进入会员专区</A>&nbsp;&nbsp;<A href="#">退出登录</A></SPAN>' ;
	}else{
		alert("用户名或密码错误");
	}
}